<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'sign.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<style type="text/css">
		body{text-align: center;}	
	</style>
	<script src="jquery/jquery-1.10.2.js"></script>
	<script type="text/javascript">
		 $(function(){
		 //密码
		 var password=$("#password1id :input").val();
		 var basePath = "<%=basePath%>";
		 $("#usernameid :input").blur(function(){
		 	//获取用户名
		 	var userNm=$(":input").val();
		 	//输出信
		 	var usres=(userNm.trim()=='');
		 	if(usres){

		 		$("#userin").html("用户名不能为空   ！   ").hide(5000);
		 	}else{	 	
			$.ajax({
			type: "POST",
         	url:basePath+"SignServlet",
         	data:{user:userNm},
         	success:function(data){
         		if('success'==data){
         			$("#userin").html("用户名可以使用  ！").hide(5000);
         		}else if('fail'==data){
         			$("#userin").html("用户名已注册  ！").hide(5000);
         		}
         	}
         	
		 }); 
		 }
		 return;
		 });
			$("#passwordid :input").blur(function(){
				var passwd=(password.trim()=='');
				if(passwd){
					$("#passwordin").html("密码不能为空  ！").hide(5000);
				}
			});
		 
		 	$("#password1id :input").blur(function(){
		 	//获取用户名
		 	var pwd=$(":input").val();
		 	//输出信
		 	var pwds=(pwd.trim()=='');
		 	if(pwds){
		 		$("#pwdin").html("密码不能为空  ！").hide(5000);
		 	}else if(password!=pwd){
		 		$("#pwdin").html("两次输入的密码不相同   ！").hide(5000);
		 		}	 	
		 	});
		});
		
	</script>


  </head>
  
  <body>
  	<h1>用户信息注册</h1>
  	<form action="<%=basePath %>SignInServlet"  method="post">
  	<table>
  		<tr id="usernameid">
  			<td>
  			用户名<input type="text" name="username" ><span id="userin"></span>
  			</td>
  		</tr>
  		<tr id="passwordid">
  			<td>
  			密码<input type="password" name="password" ><span id="passwordin"></span>
  			</td>
  			<td class="user">
  			</td>
  		</tr>
  		<tr id="password1id">
  			<td>
  			请重复上面的密码<input type="password" name="password1" ><span id="pwdin"></span>
  			</td>
  		</tr>
  		<tr>
  			<td>
  			<input type="submit" value="注册"><span>${suc}</span>
  			</td>
  		</tr>
  	</table>
  	</form>
  </body>
</html>
